Author

Tony Duan

Code
library(polyglotr)

1 Translation word

Code
word_translation <- linguee_word_translation("fruit", source_language = "en", target_language = "zh")

word_translation
[1] "水果" "果香" "果子" "果品" "实"   "檎"  

2 translate sentences

Code
google_get_supported_languages()
# A tibble: 194 × 2
   Language  `ISO-639 code`
   <chr>     <chr>         
 1 Abkhaz    ab            
 2 Acehnese  ace           
 3 Acholi    ach           
 4 Afrikaans af            
 5 Albanian  sq            
 6 Alur      alz           
 7 Amharic   am            
 8 Arabic    ar            
 9 Armenian  hy            
10 Assamese  as            
# ℹ 184 more rows
Code
texts <- c("Hello, how are you?", 
           "I love programming!", 
           "This is a test.")

languages <- c("es", "fr", "zh-CN")


create_translation_table(texts, languages)
        original_word                           es                          fr
1 Hello, how are you?           ¿Hola, cómo estás? Bonjour comment allez-vous?
2 I love programming! ¡Me encanta la programación!   J'adore la programmation!
3     This is a test.          Esta es una prueba.           Ceci est un test.
           zh-CN
1       你好吗?
2   我喜欢编程!
3 这是一个测试。
Back to top